<template>
  <content-wrap>
    <el-form
      :model="queryParams"
      ref="queryFormRef"
      :inline="true"
      label-width="100px"
      label-position="left"
    >
      <el-form-item label="客户">
        <el-select v-model="queryParams.tenantId" placeholder="请选择客户">
          <el-option
            v-for="item in customerOptions"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="">
        <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
        <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="list" :stripe="true" :show-overflow-tooltip="true" border>
      <el-table-column label="充值金额" align="center" prop="amount" />
      <el-table-column label="支付类型" align="center" prop="payType">
        <template #default="scope">
          <div>
            <el-tag v-if="scope.row.payType == 1" type="success" effect="dark">微信收款码</el-tag>
            <el-tag v-if="scope.row.payType == 2" effect="dark">支付宝收款码</el-tag>
            <el-tag v-if="scope.row.payType == 3" type="danger" effect="dark">银行卡对公</el-tag>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="备注" align="center" prop="remark" />

      <el-table-column
        label="创建时间"
        align="center"
        prop="createTime"
        :formatter="dateFormatter"
      />
    </el-table>
    <!-- 分页 -->
    <Pagination
      :total="total"
      v-model:page="queryParams.pageNo"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />
  </content-wrap>
</template>

<script setup>
import * as proxyApi from '@/api/home/proxy.ts'
import { dateFormatter } from '@/utils/formatTime'

const list = ref([])
const total = ref(0)
const queryParams = reactive({
  pageNo: 1,
  pageSize: 10,
  tenantId: null
})

const customerOptions = ref([])
/**客户列表*/
const getMyCustomer = async () => {
  customerOptions.value = await proxyApi.getProxyCustomer()
}

/**列表*/
const getList = async () => {
  const data = await proxyApi.proxyByPage(queryParams)
  list.value = data.list
  total.value = data.list
}
/**搜索*/
const handleQuery = () => {
  queryParams.pageNo = 1
  if (queryParams.tenantId == null) return
  getList()
}
/**重置*/
const resetQuery = () => {
  handleQuery()
}
onMounted(async () => {
  await getMyCustomer()
  // if (customerOptions.value.length) {
  //   queryParams.tenantId = customerOptions.value[0].id
  // }
  // getList()
})
/**删除*/
const del = () => {}
</script>

<style lang="scss" scoped></style>
